local mahjong_que_desc = [[
# 麻将模式简介

据说这是诸葛亮给张飞发明的玩具。
]]

local KleeU = require "packages/gm_mahjong/utility/k_utility"

local mahjong_que_getLogic = function ()
  ---@class MahJongQueLogic: GameLogic
  local MahJongQueLogic = GameLogic:subclass("mahjong_que_logic")
  function MahJongQueLogic:assignRoles()
    local room = self.room
    local n = #room.players
    for i = 1, n do
      local p = room.players[i]
      p.role = "hidden"
      room:setPlayerProperty(p, "role_shown", true)
      room:broadcastProperty(p, "role")
    end
    self.start_role = "hidden"
    -- for adjustSeats
    room.players[1].role = "lord"
  end

  function MahJongQueLogic:chooseGenerals()
    local room = self.room
    local lord = room:getLord() ---@cast lord ServerPlayer
    room.current = lord
    room:setPlayerProperty(lord, "role", self.start_role)

    local players = room.players
    for _, p in ipairs(players) do
      local avatar = p._splayer:getAvatar()
      if avatar == "anjiang" then avatar = table.random { "blank_shibing", "blank_nvshibing" } end
      local avatar_general = Fk.generals[avatar] or Fk.generals["diaochan"]
      if p.id < 0 then avatar_general = Fk.generals[room:getNGenerals(1)[1]] end
      room:setPlayerGeneral(p, avatar_general.name, true)
      room:broadcastProperty(p, "general")
      room:setPlayerProperty(p, "shield", 0)
      room:setPlayerProperty(p, "maxHp", 0)
      room:setPlayerProperty(p, "hp", 0)
    end
  end

  function MahJongQueLogic:broadcastGeneral()
  end

  function MahJongQueLogic:attachSkillToPlayers()
  end

  return MahJongQueLogic
end


local mahjong_que = fk.CreateGameMode{
  name = "mahjong_que",
  minPlayer = 2,
  maxPlayer = 4,
  logic = mahjong_que_getLogic,
  rule = "#mahjong_que_rule&",
  surrender_func = function(self, playedTime)
    return {{text = "#mahjong_surrender",passed = false,}}
  end,
  whitelist = {
    "mahjong_cards",
    "standard",
  },
}


Fk:loadTranslationTable {
  ["mahjong_que"] = "立直麻将",
  [":mahjong_que"] = mahjong_que_desc,

  ["#mahjong_surrender"] = "只要不放炮就算成功！(此模式禁止投降)",
}

return mahjong_que